<?php
//error_reporting(0);

/**
 * 话题推荐管理 
 * 
 * @copyright caijian
 * @since 2012-03-21
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/token/config.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();

function show_pro()
{
	/*global $g_show;
	$smarty = p_get_smarty ();
	$smarty->assign( $g_show );

	if (! empty($g_show['error']) ) {
		print $g_show['errmsg'];
		exit;
	} else {
		$smarty->display("foodv2/topic/topic_tuijian.html" );
	}
	*/
}


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	cgi::both($g_cgival["p"], "p", 1);
	cgi::both($g_cgival["pcount"], "pcount", 20);

	$g_cgival["p"] = intval($g_cgival["p"]);
	$g_cgival["pcount"] = intval($g_cgival["pcount"]);
	
}


function get_data()
{
	global $g_cgival, $g_pro, $g_show;
	
	$mblog_from_api = new mblog_from_api();
	$token_info = $mblog_from_api->api_get_user_token("",WB_AKEY,2,$g_cgival["p"],$g_cgival["pcount"]);

	
	$uid_array = array();
	foreach($token_info["data"]["list"] as $key => $value)
	{
	
		$uid_array[] =  $value["uid"];
	
	}

	$user_list = $mblog_from_api->api_get_user_info_by_uids(join(",",$uid_array));
	

	echo "已经授权用户：<br>";

	foreach($user_list["data"]["result"]  as $value)
	{
		echo "uid:{$value["id"]}| nickname:{$value["screen_name"]}<br>";
	}

	$count = $token_info["data"]["count"];
	$page_count = page_bar::get_page_max($count, $g_cgival['pcount'], $g_cgival['p']);
    if($g_cgival['p'] > $page_count){
        $g_cgival['p'] = $page_count;
    }
    $page_bar_style = array(
    'curt'	=> $g_cgival['p'],
    'max'	=> $page_count,
    'key'	=> 'p',
    );
    

	echo page_bar::bar2($page_bar_style);

	//$g_show["token_list"] = $token_info;
	

}

try
{
//	admin_check_login();
// 	admin_check_user_priv("foodv2/main_nav.php");
	
	check_cgi_pro();
	get_data();
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;

